package com.itheima.demo6list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

public class ListDemo1
{
    public static void main(String[] args) {
        List<String>list = new ArrayList<>();
        list.add("hello");
        list.add("world");
        list.add("java");
        //插入一个元素
        list.add(1,"javaee");
        //修改一个元素
        list.set(1,"javaee");
        //获取数据
        System.out.println(list.get(1));
        //强化for索引
        for (String s : list) {
            System.out.println(s);
        }
        //lambda索引
        list.forEach(s -> System.out.println(s));
        //迭代器索引
        Iterator<String> it = list.iterator();
        while(it.hasNext())
        {
            String s=it.next();
            System.out.println(s);
        }

    }
    //查询多用ArrayList 增删用LinkedList基于双链表实现
}
